<?php
namespace Back\Controller;
use Think\Controller;
use Think\Page;

/**
 * 品牌管理控制器
 * @package Back\Controller
 */
class SettingController extends Controller
{
    /**
     * 设置, 添加修改
     */
    public function setAction()
    {

        if (IS_POST) {

            $model_setting=M('Setting');
            $setting_list=I('post.setting');
            //遍历配置项
            foreach ($setting_list as $setting_id=>$value){
                //判断是否为数组类型
                if(is_array($value)){
                    $value =implode(',',$value);
                }
                //setting表模型更新
                $model_setting=save([
                    'setting_id'=>$setting_id,
                    'value'=>$value,
                ]);
            }

            //完成重定向到set(Get)
            $this->rediract('set');

                } else {
            //将配置项分组管理
            $group_setting_list=D('Setting')->groupSetting();
            trace($group_setting_list);
            $this->assign('group_setting_list',$group_setting_list);

            // 显示编辑页面
            $this->display();
        }

    }

    /**
     * ajax操作
     */
    public function ajaxAction()
    {

    }
}